<template>
	<view class="village-page page" v-if="type==1">
		<view class="title">{{detail.title}}</view>
		<view class="time">{{detail.createTime}}</view>
		<view class="content">
			<mp-html :content="detail.content"></mp-html>
		</view>
	</view>
	<view class="village-page page" v-else-if="type==2">
		<view class="title">{{detail.title}}</view>
		<view class="time">{{detail.createTime}}</view>
		<view class="content">
			<mp-html :content="detail.content"></mp-html>
		</view>
	</view>
	<view class="village-page page" v-else>
		<view class="title">{{detail.title}}</view>
		<view class="time">{{detail.createTime}}</view>
		<view class="content">
			<mp-html :content="detail.content"></mp-html>
		</view>
	</view>
</template>

<script>
	import {
		getArticleInfo,
		getRecruitDetail,
		getMerchantsDetail
	} from '@/api/article';
	export default {
		data() {
			return {
				detail: {},
				id: null
			}
		},
		methods: {
			getDetail() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getArticleInfo({
					id: this.id
				}).then(res => {
					this.detail = res;
				}).catch(() => {
					this.showToast('加载失败', () => {
						uni.navigateBack()
					})
				})
			},
			getworkDetail() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getRecruitDetail({
					id: this.id
				}).then(res => {
					this.detail = res;
				}).catch(() => {
					this.showToast('加载失败', () => {
						uni.navigateBack()
					})
				})
			},
			getBussinessDetail() {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getMerchantsDetail({
					id: this.id
				}).then(res => {
					this.detail = res;
				}).catch(() => {
					this.showToast('加载失败', () => {
						uni.navigateBack()
					})
				})
			}
		},
		onLoad(e) {
			this.id = e.id
			if (e.type) {
				this.type = e.type
				if (this.type == 1) {
					this.getworkDetail()
				}
				if (this.type == 2) {
					this.getBussinessDetail()
				}
			} else {
				this.type = 0
				this.getDetail()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.village-page {
		padding: 30rpx;
		background: #fff;

		.title {
			font-weight: bold;
			font-size: 34rpx;
		}

		.time {
			font-size: 28rpx;
			color: #999;
			margin: 20rpx 0;
		}
	}
</style>